<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="80px">
          <el-row>
            <el-col :span="5">
              <el-form-item label="门店" prop="storeId">
                <el-select
                  v-model="queryParams.storeId"
                  placeholder="请选择"
                  filterable
                  @change="changePage"
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                prop="queryType"
                label="订单筛选"
                label-width="70px"
              >
                <div class="Order_box">
                  <el-select
                    class="select_ipt"
                    v-model="queryParams.queryType"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in queryTypeOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                  <el-input
                    class="w-200"
                    v-model="queryParams.queryDesc"
                    placeholder="请输入订单号"
                    @keyup.enter.native="handleQuery"
                  ></el-input>
                </div>
              </el-form-item>
            </el-col>

            <el-col :span="7">
              <el-form-item label="支付时间" prop="time">
                <timer
                  ref="timer"
                  :timer.sync="queryParams.time"
                  :isCheck="false"
                ></timer>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <div class="pay_ipt">
                <el-form-item label="支付类型" prop="orderType">
                  <el-select
                    class="w-120"
                    v-model="queryParams.orderType"
                    placeholder="请选择"
                    @change="changePage"
                  >
                    <el-option
                      v-for="item in orderTypeOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <div class="order_ipt">
                <el-form-item label="支付方式" prop="payType">
                  <el-select
                    class="w-200"
                    v-model="queryParams.payType"
                    placeholder="请选择"
                    @change="changePage"
                  >
                    <el-option
                      v-for="item in payWayOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>

    <!-- 流水管理列表 -->
    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left"></span>
        <div class="table_card_title">流水管理列表</div>
        <div class="op_right"></div>
      </div>

      <div class="table_list">
        <el-table
          :data="WaterList"
          stripe
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column
            prop="payNo"
            label="支付订单"
            :show-overflow-tooltip="true"
            width="170px"
          >
            <template slot-scope="scope">
              <div @click="PayOrder(scope.row)" style="color: #0079fe">
                <span class="payNo">{{ scope.row.payNo }}</span>
              </div>
            </template>
          </el-table-column>

          <!-- <el-table-column
            prop="orderNo"
            label="关联订单"
            :show-overflow-tooltip="true"
            width="170px"
          >
          </el-table-column> -->
          <el-table-column prop="storeName" label="关联门店"> </el-table-column>
          <el-table-column prop="payWant" label="账单金额"> </el-table-column>
          <el-table-column prop="payPre" label="优惠金额"> </el-table-column>
          <el-table-column prop="moneyCard" label="抵扣金额"> </el-table-column>
          <el-table-column prop="payReal" label="实收金额"> </el-table-column>
          <el-table-column prop="orderType" label="支付类型"> </el-table-column>
          <el-table-column prop="payType" label="支付方式"> </el-table-column>
          <el-table-column prop="userName" label="操作人"> </el-table-column>
          <el-table-column prop="createTime" label="支付时间" width="200">
          </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNo"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { getWaterList } from "@/api/business/order";
import timer from "@/components/getTime/timer";
export default {
  name: "Storeadminwater",
  components: { timer },
  data() {
    return {
      WaterList: [],
      loading: false,

      queryTypeOptions: [
        {
          value: "O",
          label: "订单编号",
        },
        {
          value: "P",
          label: "支付单号",
        },
        {
          value: "L",
          label: "关联单号",
        },
      ],

      orderTypeOptions: [
        {
          value: "",
          label: "全部",
        },
        {
          value: "C",
          label: "会员卡充值",
        },
        {
          value: "S",
          label: "支付订单",
        },
      ],

      payWayOptions: [
        {
          value: "",
          label: "全部",
        },
        {
          value: "W",
          label: "微信",
        },
        {
          value: "Z",
          label: "支付宝",
        },
        {
          value: "R",
          label: "人民币",
        },
        {
          value: "P",
          label: "POS",
        },
        {
          value: "C",
          label: "会员卡",
        },
      ],

      newClientRules: {
        name: [{ required: true, message: "请输入客户姓名", trigger: "blur" }],
        iphone1: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入6位数消费密码", trigger: "blur" },
        ],
        sex: [{ required: true, message: "请输入活动名称", trigger: "blur" }],
        source: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
      },

      newGoodForm: {
        name: "",
        iphone1: "",
        iphone2: "",
        password: "",
        sex: "",
        birthday: "",
        member: "",
        source: "",
      },

      value: "",
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        queryType: "",
        queryDesc: "",
        orderType: null,
        payType: null,
        time: [], // 支付时间
      },
      total: 0,
    };
  },

  mounted() {},

  created() {
    this.getList();
  },

  methods: {
    changePage() {
      this.getList();
    },

    PayOrder(row) {
      this.$router.push({
        path: "/storeAdminfinance/storeAdminWaterDetail",
        query: { payId: row.payId },
      });
    },

    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$refs[formName].resetFields();
    },

    // 订单列表
    getList() {
      this.loading = true;
      let queryParams = JSON.parse(JSON.stringify(this.queryParams));

      if (!!this.queryParams.time) {
        queryParams.orderStartTime = this.queryParams.time[0];
        queryParams.orderEndTime = this.queryParams.time[1];
      }

      getWaterList(queryParams)
        .then((res) => {
          console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.WaterList = data.list;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: 2px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

// .order_ipt {
//   margin-left: -120px;
// }
.table_list {
  .payNo {
    cursor: pointer;
  }
}
</style>
